package com.youlu.campus.admin.community.controller;

import com.youlu.campus.admin.annotation.AuthParamTypeEnum;
import com.youlu.campus.admin.annotation.RequestActivityAuth;
import com.youlu.campus.entity.ActivityRewardRule;
import com.youlu.campus.entity.VO.req.ActivityRewardRuleQueryVO;
import com.youlu.campus.service.activity.ActivityRewardRuleService;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: zhuhuaiqi
 * @date: 2021/2/27
 */
@Slf4j
@RestController
public class ActivityRewardRuleController {
    @Autowired
    private ActivityRewardRuleService activityRewardRuleService;

    @PostMapping("/activity/reward-rule/create")
    @RequestActivityAuth(activityId = "#req.taskId",paramType = AuthParamTypeEnum.TASK)
    public QResult create(@RequestBody ActivityRewardRule req) {
        return QResult.success(activityRewardRuleService.create(req));
    }

    @PostMapping("/activity/reward-rule/update")
    @RequestActivityAuth(activityId = "#req.taskId",paramType = AuthParamTypeEnum.TASK)
    public QResult update(@RequestBody ActivityRewardRule req) {
        return QResult.success(activityRewardRuleService.update(req));
    }

    @GetMapping("/activity/reward-rule/find-one")
    public QResult findOne(@RequestParam("id") String id) {
        return QResult.success(activityRewardRuleService.findOne(id));
    }

    @GetMapping("/activity/reward-rule/delete")
    @RequestActivityAuth(activityId = "#id",paramType = AuthParamTypeEnum.TASK_RULE)
    public QResult delete(@RequestParam("id") String id) {
        return QResult.success(activityRewardRuleService.delete("", id));
    }

    @PostMapping("/activity/reward-rule/list")
    public QResult list(@RequestBody ActivityRewardRuleQueryVO req) {
        return QResult.success(activityRewardRuleService.list(req));
    }
}
